/* mrmpupe.p - INITIALIZE WORKFILES FOR MRP REGENERATION                */
/* Copyright 1986-2005 QAD Inc., Carpinteria, CA, USA.                  */
/* All rights reserved worldwide.  This is an unpublished work.         */
/* $Revision: 1.7.1.2.3.1 $                                                         */
/*V8:ConvertMode=Maintenance                                            */
/* REVISION: 4.0       LAST EDIT: 05/24/88      MODIFIED BY: EMB *A249* */
/* REVISION: 1.0       LAST EDIT: 07/16/86      MODIFIED BY: EMB      */
/* REVISION: 1.0       LAST EDIT: 01/28/87      MODIFIED BY: EMB *A19* */
/* REVISION: 2.0       LAST EDIT: 03/11/87      MODIFIED BY: EMB *A40* */
/* REVISION: 2.0       LAST EDIT: 07/20/87      MODIFIED BY: EMB *A75* */
/* REVISION: 4.0       LAST EDIT: 01/05/88      MODIFIED BY: EMB *A120* */
/* REVISION: 4.0       LAST EDIT: 01/20/88      MODIFIED BY: pml *A158* */
/* REVISION: 4.0       LAST EDIT: 04/04/88      MODIFIED BY: emb *A162* */
/* REVISION: 4.0       LAST EDIT: 02/05/88      MODIFIED BY: emb *A173* */
/* REVISION: 4.0       LAST EDIT: 03/23/88      MODIFIED BY: RL  *A171* */
/* REVISION: 4.0       LAST EDIT: 06/21/88      MODIFIED BY: emb *A256* */
/* REVISION: 5.0       LAST EDIT: 11/02/88      MODIFIED BY: emb *B001* */
/* REVISION: 5.0       LAST EDIT: 11/28/88      MODIFIED BY: emb *B003* */
/* REVISION: 5.0       LAST EDIT: 02/09/89      MODIFIED BY: emb *A643* */
/* REVISION: 5.0       LAST EDIT: 03/02/90      MODIFIED BY: emb *B602* */
/* REVISION: 6.0       LAST EDIT: 07/06/90      MODIFIED BY: EMB *D040*/
/* REVISION: 6.0       LAST EDIT: 04/29/91      MODIFIED BY: emb *D594*/
/* REVISION: 6.0       LAST EDIT: 10/22/91      MODIFIED BY: emb *D904*/
/* REVISION: 7.0       LAST EDIT: 07/29/92      MODIFIED BY: emb *F817**/
/* REVISION: 7.3       LAST EDIT: 10/19/92      MODIFIED BY: emb *G208**/
/* Revision: 7.3        Last edit: 09/27/93             By: jcd *G247* */
/* REVISION: 7.0       LAST EDIT: 06/07/93      MODIFIED BY: WUG *GB79**/
/* REVISION: 7.3       LAST EDIT: 09/23/93      MODIFIED BY: emb *GF79**/
/* REVISION: 7.3       LAST EDIT: 10/15/93      MODIFIED BY: pxd *GG31**/
/* REVISION: 7.3       LAST EDIT: 02/25/94      MODIFIED BY: pxd *FM41**/
/* REVISION: 7.3       LAST EDIT: 09/01/94      MODIFIED BY: ljm *FQ67**/
/* REVISION: 7.3       LAST EDIT: 01/13/95      MODIFIED BY: WUG *G0CN**/
/* REVISION: 7.3       LAST EDIT: 02/14/95      MODIFIED BY: pxd *F0HX**/
/* REVISION: 7.3       LAST EDIT: 03/15/95      MODIFIED BY: aed *G0HL**/
/* REVISION: 7.3       LAST EDIT: 03/22/95      MODIFIED BY: smp *F0N4**/
/* REVISION: 7.3       LAST EDIT: 05/06/95      MODIFIED BY: emb *F0SQ**/
/* REVISION: 8.6       LAST EDIT: 05/20/98      BY: *K1Q4* Alfred Tan   */
/* REVISION: 8.6       LAST EDIT: 06/04/98      BY: *G2S9* Viswanathan M*/
/* REVISION: 9.1      LAST EDIT: 08/13/00     BY: *N0KR* myb              */
/* REVISION: 9.1      LAST MODIFIED: 08/29/00 BY: *N0PP* Jean Miller      */
/* Old ECO marker removed, but no ECO header exists *F0PN*                    */
/* $Revision: 1.7.1.2.3.1 $    BY: Max Iles             DATE: 12/20/04  ECO: *P311*  */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

{mfdeclre.i "new global "}

{pxpgmmgr.i}

define variable i as integer no-undo.
define variable oldfc_qty like fc_qty.
define variable fcsduedate as date.
define variable week as integer.
define new shared variable fcs_recid as recid.
define new shared variable nett like fcs_fcst_qty extent 156.
define new shared variable start as date extent 52.
define variable open_qty as decimal no-undo.

define variable mrptype like mrp_type.

define new shared variable frwrd like soc_fcst_fwd initial 0.
define new shared variable bck    like soc_fcst_bck initial 0.
define variable yn like mfc_logical.
define variable conf_msg as character format "x(40)" no-undo.

SESSION:DATE-FORMAT = "ymd".

base_curr = "RMB".
global_userid = "mfg".
global_user_lang = "ch".
global_user_lang_dir = "ch/".

{fcsdate.i today fcsduedate week global_site}
    
find first soc_ctrl no-lock no-error.
if available soc_ctrl then do:
    assign
        fcsduedate = fcsduedate - 7 * soc_fcst_bck
        frwrd = soc_fcst_fwd
        bck = soc_fcst_bck.
end.

output to value("c:\mrmpup.txt").

export string(time, "HH:MM:SS").
         
/* DELETE RECORDS AS NECESSARY */
{gprun.i ""mrmpupe1.p""}
/*GUI*/ if global-beam-me-up then undo, leave.

/* LOAD DEMAND & SUPPLY RECORDS INTO mrp_det
(sales orders & forecasts) */
{gprun.i ""mrmpupe2.p""}
/*GUI*/ if global-beam-me-up then undo, leave.

/* Work Orders */
{gprun.i ""mrmpupe3.p""}
/*GUI*/ if global-beam-me-up then undo, leave.

/* Purchasing */
{gprun.i ""mrmpupe4.p""}
/*GUI*/ if global-beam-me-up then undo, leave.
    
/* DRP Intersite Requests */
{gprun.i ""mrmpupe5.p""}
/*GUI*/ if global-beam-me-up then undo, leave.

export string(time, "HH:MM:SS").

output close.

quit.
